<template>
  <el-table :data="tableData" style="width: 100%">
    <!-- <el-table-column prop="createdAt" label="注册时间" /> -->
    <el-table-column label="注册时间" width="220">
      <template #default="scoped">
        <span>{{ dateFormat(scoped.row.createdAt) }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="nickName" label="昵称" />
    <el-table-column prop="userName" label="用户名" />
    <el-table-column label="操作" width="220">
      <template #default>
        <el-button link type="primary" size="small" @click="handleedit"
          >修改</el-button
        >
        <el-button link type="primary" size="small">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
  <el-pagination background layout="prev, pager, next" :total="total" />
</template>

<script setup lang="ts">
import { ref } from "vue";
import { reqUsers } from "../../service/user";
const tableData = ref([]);
let total = ref(10);
const users = async () => {
  const result = await reqUsers();
  tableData.value = result.data.list;
  console.log(232323, tableData.value);
};
users();
const handleedit = () => {};
const dateFormat = time => {
  var data = new Date(time);
  // 封装年份时间
  var y = data.getFullYear();
  // 封装月份时间
  var m = data.getMonth();
  // 封装日期时间
  var d = data.getDate();
  // 转换详细时分
  var hours = data.getHours() < 10 ? "0" + data.getHours() : data.getHours();
  var minutes =
    data.getMinutes() < 10 ? "0" + data.getMinutes() : data.getMinutes();
  // 输出转换后时间节点
  return `${y}-${m}-${d} ${hours}:${minutes}`;
};
</script>

<style lang="scss" scoped></style>
